<link rel="stylesheet" href="/opebs/css/bootstrap.min.css">
<link rel="stylesheet" href="/opebs/date/css/bootstrap-datetimepicker.css">
<link rel="stylesheet" href="/opebs/css/bootstrap-select.css">
<script src="/opebs/js/jquery.min.js"></script>
<script src="/opebs/js/bootstrap.min.js"></script>
<script src="/opebs/js/bootstrap-select.js"></script>
<script src="/lib/jquery.form.js"></script>
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>

<link rel="stylesheet" href="/opebs/date/css/bootstrap-datetimepicker.min.css">
<script src="/opebs/date/js/bootstrap-datetimepicker.min.js"></script>


<link href="/lib/ueditor/themes/css/umeditor.css" type="text/css" rel="stylesheet">
<script type="text/javascript" charset="utf-8" src="/lib/ueditor/js/umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/lib/ueditor/js/editor_api.js"></script>
<script type="text/javascript" src="/lib/ueditor/lang/zh-cn/zh-cn.js"></script>



<#include "/common/h-ui-base-css.html">
<#include "/common/validation-js.html">

<body>
    <div class="page-container">
        <form action="" method="post" class="form form-horizontal" id="form-project-add">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目编号：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proId!}" style="background-color: #8eaf84" placeholder=""  readonly>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目名称：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proName!}" style="background-color: #8eaf84" placeholder=""  readonly >
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目类别：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proCategory!}" style="background-color: #8eaf84" placeholder=""  readonly >
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目状态：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${proState!}"style="background-color: #8eaf84" placeholder=""  readonly >
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目所属公司：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proCompany!}" style="background-color: #8eaf84" placeholder=""  readonly >
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">项目实际投资时间：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proRealInvestmentTime!}" id="proRealInvestmentTime" name="proRealInvestmentTime">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">项目付款时间：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proPaymentTime!}" id="proPaymentTime" name="proPaymentTime">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">付款方式：</label>
                <div class="formControls col-xs-8 col-sm-9">
                        <select  id="proPaymentMethod" name="proPaymentMethod"  class="selectpicker form-control"  data-live-search="true"
                                 onchange="show_payDetailButton(this.options[this.options.selectedIndex].value)">
                             <option>请选择</option>
                            <#if proPaymentMethod??>
                                <#list proPaymentMethod as list>
                                    <option value="${list.key}" <#if project.proPaymentMethod??><#if list.key==project.proPaymentMethod>selected</#if></#if>>${list.text}</option>
                                </#list>
                            </#if>
                        </select>
                    <div id="payDetail" style="display: none"><p class="form-control-static"><button class="btn btn-primary" data-toggle="button" onclick="paydetail()">详情</button></p></div>
                </div>
            </div>


            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">项目付款金额：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proPaymentMoney!}" id="proPaymentMoney" name="proPaymentMoney">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">每股价格：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proSharePrice!}" id="proSharePrice" name="proSharePrice">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">项目投资股权比例：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proRealProportion!}" id="proRealProportion" name="proRealProportion">
                </div>
            </div>
            <div class="row cl" >
                <label class="form-label col-xs-4 col-sm-2">项目合同主要条款：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proContent!}" id="proContent" name="proContent">
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                    <button  class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
                </div>
            </div>
            <input type="text" hidden id="proTouziFlag" name="proTouziFlag" value="1">
            <input type="text" hidden id="id" name="id" value="${project.id}">
        </form>
    </div>
</body>



<script>
    function show_payDetailButton(val){
        if(val == "1"){
            $('#payDetail').css('display','');
        }else {
            $('#payDetail').css('display','none');
        }
    }

    function paydetail(){
        var id = $('#id').val();
        var url = '/project-payment-detail/'+id;
        var index = layer.open({
            title:'分期详情',
            type: 2,
            area: ['700px', '450px'],
            fixed: true, //不固定
            maxmin: true,
            end:function () {

            },
            content: url
        });
        layer.full(index);
    }
                //页面加载初始化尽调方式
                $(document).ready(function(){
                    var proPaymentMethod = $('#proPaymentMethod').val();
                    show_payDetailButton(proPaymentMethod);
                });
</script>

<script type="text/javascript">

    // var um = UM.getEditor('myEditor',{
    //     //这里可以选择自己需要的工具按钮名称,此处仅选择如下七个
    //     toolbar:['fullscreen source undo redo bold italic underline'],
    //     //focus时自动清空初始化时的内容
    //     autoClearinitialContent:false,
    //     //关闭字数统计
    //     wordCount:false,
    //     //关闭elementPath
    //     elementPathEnabled:false,
    //     //默认的编辑区域高度
    //     initialFrameHeight:300
    //     //更多其他参数，请参考umeditor.config.js中的配置项
    // });

    $(function(){
        $("#proRealInvestmentTime").datetimepicker({
            format:'yyyy-mm-dd',  //格式  如果只有yyyy-mm-dd那就是0000-00-00
            autoclose:true,//选择后是否自动关闭
            minView:2,//最精准的时间选择为日期  0-分 1-时 2-日 3-月
            language:  'zh-CN', //中文
            weekStart: 1, //一周从星期几开始
            todayBtn:  1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            // daysOfWeekDisabled:"1,2,3", //一周的周几不能选 格式为"1,2,3"  数组格式也行
            todayBtn : true,  //在底部是否显示今天
            todayHighlight :true, //今天是否高亮显示
            keyboardNavigation:true, //方向图标改变日期  必须要有img文件夹 里面存放图标
            showMeridian:false,  //是否出现 上下午
            initialDate:new Date()
            //startDate: "2017-01-01" //日期开始时间 也可以是new Date()只能选择以后的时间
        }).on("changeDate",function(){
            var start = $("#start").val();
        });

        $("#proPaymentTime").datetimepicker({
            format:'yyyy-mm-dd',  //格式  如果只有yyyy-mm-dd那就是0000-00-00
            autoclose:true,//选择后是否自动关闭
            minView:2,//最精准的时间选择为日期  0-分 1-时 2-日 3-月
            language:  'zh-CN', //中文
            weekStart: 1, //一周从星期几开始
            todayBtn:  1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            // daysOfWeekDisabled:"1,2,3", //一周的周几不能选 格式为"1,2,3"  数组格式也行
            todayBtn : true,  //在底部是否显示今天
            todayHighlight :true, //今天是否高亮显示
            keyboardNavigation:true, //方向图标改变日期  必须要有img文件夹 里面存放图标
            showMeridian:false,  //是否出现 上下午
            initialDate:new Date()
            //startDate: "2017-01-01" //日期开始时间 也可以是new Date()只能选择以后的时间
        }).on("changeDate",function(){
            var start = $("#start").val();
        });

    });
</script>

<script type="text/javascript">
    $("#form-project-add").validate({
        rules:{
            proPaymentMoney:{
                required:true,
                number : true
            },
            proRealInvestmentTime:{
                required:true
            } ,
            proPaymentTime:{
                required:true
            } ,
            proRealProportion:{
                required:true
            } ,
            proContentr:{
                required:true
            }
        },
        onkeyup:false,
        focusCleanup:true,
        success:"valid",
        submitHandler:function(form){
            var id = ${project.id!}

            // var proRealInvestmentTime = $('#proRealInvestmentTime').val();
            // var proPaymentTime = $('#proPaymentTime').val();
            // var proPaymentMoney = $('#proPaymentMoney').val();
            // var proRealProportion = $('#proRealProportion').val();



            $(form).ajaxSubmit({
                type: 'post',
                url: "/project-ins-upd-del/"+id ,
                data :$("form-project-add").serialize(),
                // data :{proRealInvestmentTime:proRealInvestmentTime,proPaymentTime:proPaymentTime,proPaymentMoney:proPaymentMoney,proRealProportion:proRealProportion,proContent:content},
                async:false,
                success: function(data){
                    layer.msg('添加成功!',{icon:1,time:1000});
                },
                error: function(XmlHttpRequest, textStatus, errorThrown){
                    layer.msg('error!',{icon:1,time:1000});
                }
            });
            var index = parent.layer.getFrameIndex(window.name);
            var refreshFlag = ${refreshFlag!};
            if(refreshFlag == 0){
                var handler = '/project-list/3/1/20';
                parent.$('#project_table').datagrid('options').url = handler;
                parent.$('#project_table').datagrid('reload');
            }else if(refreshFlag == 1){
                parent.location.reload();
            }

            parent.layer.close(index);
        }
    });
</script>
